<?php

namespace App\Http\Middleware;

use Closure;

/**
 * IM登录身份中间件
 * Class ImAuth
 * @package App\Http\Middleware
 */
class ImAuth
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $user = session('user');

        if(!$user){
            //用户未登录重定向到login页面
            return redirect('login');
        }

        return $next($request);
    }
}
